/*
 * @Author: askMeWhy
 * @Date:   2018-08-09 18:57:31
 * @Last Modified by: AskMeWhy
 * @Last Modified time: 2020-08-06 11:14:02
 */
import Vue from "vue";
import ComponentTemplate from "./editor-toolbar-upload.vue";
const VueComponent = Vue.extend(ComponentTemplate);

export const editorToolBarUpload = option => {
    const vm = new VueComponent().$mount();
    if (option.limitImage.value === 0 || option.limitImage.value) {
        vm.limitImage = option.limitImage;
    }
    if (option.limitVideo.value === 0 || option.limitVideo.value) {
        vm.limitVideo = option.limitVideo;
    }
    vm.uploadType = option.type || "image";
    vm.path = option.path || "";
    vm.$on("onchange", item => {
        if (option && option.onChange) option.onChange(vm, item);
    });
    vm.$on("sure", model => {
        if (option && option.sure) option.sure(vm, model);
    });
    vm.show = true;
    return vm;
};
